import matplotlib.pyplot as plt
from skimage.feature import local_binary_pattern
from skimage import data

# LBP 参数设置
radius = 3
n_points = 8 * radius

# 使用灰度图像
image = data.brick()

# 计算 LBP 特征
lbp_image = local_binary_pattern(image, n_points, radius, 'uniform')

# 绘制原图和 LBP 特征图
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 6), sharex=True, sharey=True)
ax1.imshow(image, cmap='gray')
ax1.set_title('Original Image')
ax1.axis('off')

ax2.imshow(lbp_image, cmap='gray')
ax2.set_title('LBP Feature Image')
ax2.axis('off')

plt.show()
